package com.android.datasave;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class LogAcces {

	private static final int VERSION_BDD = 1;
	private static final String NOM_BDD = "log.db";
 
	private static final String TABLE_LOG = "table_log";
	private static final String COL_DATE = "Date";
	private static final int NUM_COL_ID = 0;
	private static final String COL_DATA = "Data";
	private static final int NUM_COL_ISBN = 1;
	
	private SQLiteDatabase db;
	
	private LogDataBase logDataBase;
	
	public LogAcces(Context context){
		logDataBase = new LogDataBase(context, NOM_BDD, null, VERSION_BDD);
	}
	
	public void open(){
		db = logDataBase.getWritableDatabase();
	}
	
	public void close(){
		db.close();
	}
	
	public SQLiteDatabase getDB(){
		return db;
	}
	
	public long insertLog(Log log){
		ContentValues values = new ContentValues();
		values.put(COL_DATE, log.getDate());
		values.put(COL_DATA, log.getData());
		return db.insert(TABLE_LOG, null, values);
	}
	
}
